﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ICSharpCode.WinFormsUI.Controls
{
    public class NToolStripTextBox : System.Windows.Forms.ToolStripTextBox
    {
        private bool focusStatus = false;

        public NToolStripTextBox() : base()
        {
            this.Padding = new Padding(2);
            this.TextBox.Dock = DockStyle.Fill;
            this.TextBox.BorderStyle = BorderStyle.None;            
        }
        
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(Brushes.White, new Rectangle(0, 2, Width, Height - 4));
            base.OnPaint(e);          
            if (focusStatus)
            {
                e.Graphics.DrawRectangle(new Pen(SystemColors.ControlDark), new Rectangle(0, 2, Width - 1, Height - 6));
            }
        }

        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);
            focusStatus = false;
            Invalidate();
        }

        protected override void OnGotFocus(EventArgs e)
        {
            base.OnGotFocus(e);
            focusStatus = true;
            Invalidate();
        }
    }
}
